# -*- coding: utf-8 -*-
'''
    date:2017-05-28 hqk
    spider newadd rest class
'''
import os
import oss2
from config.setting import BUCKETDIANP, OSSKEYID, OSSKEYSECRET, OSSENDPOINT

class DianpOss():
    def __init__(self):
        auth = oss2.Auth(OSSKEYID, OSSKEYSECRET)
        self.bucket = oss2.Bucket(auth, OSSENDPOINT, BUCKETDIANP)
        
    def upload(self, pathName, data):
        self.bucket.put_object(pathName, data)
        
    def bulid_oss_path(self, restid, tag, name):
        return os.path.join(restid, tag, name+'.jpg')
        

    
